﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using BusinessLogicLayer;

namespace UserInterfaceLayer
{
    [Serializable]
    class Room_ViewStateItem
    {
        public int RoomID { get; set; }
        public DateTime From { get; set; }
        public DateTime To { get; set; }

        public string hijriFrom
        {
            get
            {
                return From.ToHijriSolarString();
            }
        }

        public string hijriTo
        {
            get
            {
                return To.ToHijriSolarString();
            }
        }
    }

    [Serializable]
    class Person_ViewStateItem
    {
        public int PersonID { get; set; }
    }

    class Room_ListViewItem_Pro
    {
        public Room_ViewStateItem Room { get; set; }
        public DataAccessLayer.Room dRoom { get; set; }
        public BusinessLogicLayer.DataObject.Room bRoom { get; set; }

        public Room_ListViewItem_Pro(DataAccessLayer.linqDatabaseDataContext db, Room_ViewStateItem Room)
        {
            this.Room = Room;
            dRoom = DataAccessLayer.Room.FindByRoomID(db, Room.RoomID);
            bRoom = new BusinessLogicLayer.DataObject.Room(dRoom);
        }

        public static List<Room_ListViewItem_Pro> Convert(DataAccessLayer.linqDatabaseDataContext db, List<Room_ViewStateItem> Rooms)
        {
            List<Room_ListViewItem_Pro> Result = new List<Room_ListViewItem_Pro>();
            foreach (Room_ViewStateItem Item in Rooms)
                Result.Add(new Room_ListViewItem_Pro(db, Item));
            return Result;
        }
    }

    class Person_ViewStateItem_Pro
    {
        public Person_ViewStateItem Person { get; set; }
        public DataAccessLayer.Person dPerson { get; set; }
        public BusinessLogicLayer.DataObject.Person bPerson { get; set; }
        public bool Headman { get; set; }

        public Person_ViewStateItem_Pro(DataAccessLayer.linqDatabaseDataContext db, Person_ViewStateItem Person)
        {
            this.Person = Person;
            dPerson = DataAccessLayer.Person.FindByPersonID(db, Person.PersonID);
            bPerson = new BusinessLogicLayer.DataObject.Person(dPerson);
        }

        public static List<Person_ViewStateItem_Pro> Convert(DataAccessLayer.linqDatabaseDataContext db, List<Person_ViewStateItem> Persons)
        {
            List<Person_ViewStateItem_Pro> Result = new List<Person_ViewStateItem_Pro>();
            foreach (Person_ViewStateItem Item in Persons)
                Result.Add(new Person_ViewStateItem_Pro(db, Item));
            return Result;
        }
    }
}